<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<link href="<c:url value='/css/easyui.css'/>" rel="stylesheet">
<link href="<c:url value='/css/icon.css'/>" rel="stylesheet">
<script src="<c:url value='/js/cdsf_map.js'/>"></script>
<script src="<c:url value='/js/jquery.min.js'/>"></script>
<script type="text/javascript"
	src="<c:url value='/js/jquery.easyui.min.js'/>"></script>
<script src="<c:url value='/js/do_interface.js'/>"></script>
<script type="text/javascript">
var type = "${cInterface.itype}";
	$(document).ready(
			function() {	
				$("#itype").val(type);
			});
</script>
<div class="page-header">
	<h3 style="margin-top: auto">更新接口信息</h3>
</div>
<div class="row-fluid">
	<div>
		<form class="form-horizontal"
			action="<%=request.getContextPath()%>/interface/${uri}/update"
			method="POST" onsubmit="return valid()">
			<div class="control-group" id="div_name">
				<label class="control-label">名称</label>
				<div class="controls">
					<input type="hidden" id="uri" name="uri" value="${uri}"> <input
						type="text" id="name" name="name" value="${cInterface.name}">
					<span class="help-inline" id="help_name">英文</span>
				</div>
			</div>
			<div class="control-group" id="div_type">
				<label class="control-label">类别</label>
				<div class="controls">
					<select style="width: 200px" id="itype" name="itype"
							tabindex="1">
							<option value="总线通信">总线通信</option>
							<option value="控制响应">控制响应</option>
							<option value="IO通信">IO通信</option>
							<option value="信息显示">信息显示</option>
							<option value="其他">其他</option>
					</select>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">描述信息</label>
				<div class="controls">
					<textarea rows="3" class="input-xxlarge" id="description"
						name="description" style="float: left"><c:out value="${cInterface.description}" /></textarea>
				</div>
			</div>
			
					<div class="control-group">
						<label class="control-label">函数列表</label>

						<div id="list">
						<c:choose>
							<c:when test="${!empty cInterface.interfaceMethods}">
								<c:forEach items="${cInterface.interfaceMethods}" var="list"
									varStatus="s">
									<div class="controls">
										<code><c:out value="${list.methodSigniture}" /></code>
									</div>
									<br />
								</c:forEach>
							</c:when>
						</c:choose>
						</div>
					</div>
			<div class="control-group" id="div_interface">
				<div class="controls">
					<button type="button" class="btn" id="btn_add_div"
						onclick="add_interface()"><i class="icon-plus"></i>&nbsp;添加函数</button>
					<span class="help-inline" id="help_interface"></span>
				</div>
			</div>
			<div class="control-group">
				<div class="controls">
					<button type="submit" class="btn" id="submit"><i class="icon-ok"></i>&nbsp;提交</button>
					<button type="button" style="margin-left:50px;"class="btn" onclick="goback()"><i class="icon-remove"></i>&nbsp;取消</button>
				</div>
			</div>
		</form>
	</div>
</div>

<div id="addInterface" class="easyui-dialog" title="添加函数"
	style="width: 600px; height: auto; padding: 10px" closed="true"
	data-options="iconCls: 'icon-add-dialog'" buttons="#dlg-buttons">
	<div>
		<div class="control-group">
			<div class="controls">
			<div class="form-inline">返回类型&nbsp;&nbsp;
				<select style="width: 400px" id="return_type">
					<c:choose>
						<c:when test="${!empty typeList}">
							<c:forEach items="${typeList}" var="item">
								<option value="${item.id}">
									<c:out value="${item.name}" />
								</option>
							</c:forEach>
						</c:when>
					</c:choose>
				</select>
			</div>
			</div>
		</div>
		<div class="control-group">
			<div class="controls" id="fun_name_group">
			<div class="form-inline">函数名称&nbsp;&nbsp;
				<input type="text" class="input-xlarge" placeholder="函数名称"
					id="fun_name"><span class="help-inline" id="help_fun_name">英文</span>
			</div>
			</div>
		</div>
		<div class="control-group">
			<div class="controls" id="fun_signature_group">
				<div class="form-inline">函数签名&nbsp;&nbsp;
					<input type="text" style="width: 450px" placeholder="函数签名(默认生成)"
						id="fun_signature">
				</div>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">参数列表</label>
			<div id="param_list"></div>
			<div class="controls" id="param_name_group">
				<select style="width: 250px" id="param_type">
					<c:choose>
						<c:when test="${!empty typeList}">
							<c:forEach items="${typeList}" var="item">
								<option value="${item.id}">
									<c:out value="${item.name}" />
								</option>
							</c:forEach>
						</c:when>
					</c:choose>
				</select> <input type="text" class="input-large" placeholder="参数名称"
					id="fun_param_name"> <button type="button" style="margin-bottom: 12px" class="btn" id="btn_add_param"><i class="icon-plus"></i>&nbsp;添加</button>
			</div>
		</div>
		<div class="control-group">
			<div class="controls">
				<div class="form-inline">
				描述信息&nbsp;&nbsp;
					<textarea rows="1" class="input-xxlarge" placeholder="描述信息"
						id="fun_des"></textarea>
				</div>
			</div>

		</div>
	</div>
		<div id="dlg-buttons" style="float: right;">
			<a href="javascript:void(0)" class="easyui-linkbutton"
				iconCls="icon-ok-dialog" onclick="dlgOK()">确定</a> <a
				href="javascript:void(0)" class="easyui-linkbutton"
				iconCls="icon-cancel-dialog" onclick="dlgCancel()">取消</a>
		</div>
		<script type="text/javascript">
			$(function() {
				$('#addInterface').dialog('close');
			});
			function dlgOK(){
				$('#addInterface').dialog('close');
				addFunction();
			}
			function dlgCancel(){
				$('#addInterface').dialog('close');
				refreshAddDiv();
			}
		</script>